Visual Basic (Declaration) | |
---|---|
Public Overloads Shared Function Merge( _ ByVal comparer As IComparer(Of TKey), _ ByVal duplicateHandling As DuplicateHandling, _ ByVal ParamArray enums() As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _ ) As IEnumerable(Of KeyValuePair(Of TKey,TValue)) |
C# | |
---|---|
public static IEnumerable<KeyValuePair<TKey,TValue>> Merge( IComparer<TKey> comparer, DuplicateHandling duplicateHandling, params IEnumerable<KeyValuePair<TKey,TValue>>[] enums ) |
Parameters
- comparer
- duplicateHandling
- enums
Library/Library.Test/TestOrderedEnumeration.cs
C# | Copy Code |
---|---|
var x = new[] { new KeyValuePair<int, int>(1, 1) }; var y = new[] { new KeyValuePair<int, int>(1, 2), new KeyValuePair<int, int>(2, 2) }; IEnumerator<KeyValuePair<int, int>> e = OrderedKeyValuePairs<int, int> .Merge(Comparer<int>.Default, DuplicateHandling.FirstValueWins, x, y) .GetEnumerator(); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(1, e.Current.Key); Assert.AreEqual(1, e.Current.Value); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(2, e.Current.Key); Assert.AreEqual(2, e.Current.Value); Assert.IsFalse(e.MoveNext()); e = OrderedKeyValuePairs<int, int> .Merge(Comparer<int>.Default, DuplicateHandling.LastValueWins, x, y) .GetEnumerator(); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(1, e.Current.Key); Assert.AreEqual(2, e.Current.Value); Assert.IsTrue(e.MoveNext()); Assert.AreEqual(2, e.Current.Key); Assert.AreEqual(2, e.Current.Value); Assert.IsFalse(e.MoveNext()); |
VB.NET | Copy Code |
---|---|
Dim x As var = New () {New KeyValuePair(Of Integer, Integer)(1, 1)} Dim y As var = New () {New KeyValuePair(Of Integer, Integer)(1, 2), New KeyValuePair(Of Integer, Integer)(2, 2)} Dim e As IEnumerator(Of KeyValuePair(Of Integer, Integer)) = OrderedKeyValuePairs(Of Integer, Integer).Merge(Comparer(Of Integer).[Default], DuplicateHandling.FirstValueWins, x, y).GetEnumerator() Assert.IsTrue(e.MoveNext()) Assert.AreEqual(1, e.Current.Key) Assert.AreEqual(1, e.Current.Value) Assert.IsTrue(e.MoveNext()) Assert.AreEqual(2, e.Current.Key) Assert.AreEqual(2, e.Current.Value) Assert.IsFalse(e.MoveNext()) e = OrderedKeyValuePairs(Of Integer, Integer).Merge(Comparer(Of Integer).[Default], DuplicateHandling.LastValueWins, x, y).GetEnumerator() Assert.IsTrue(e.MoveNext()) Assert.AreEqual(1, e.Current.Key) Assert.AreEqual(2, e.Current.Value) Assert.IsTrue(e.MoveNext()) Assert.AreEqual(2, e.Current.Key) Assert.AreEqual(2, e.Current.Value) Assert.IsFalse(e.MoveNext()) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
OrderedKeyValuePairs<TKey,TValue> ClassOrderedKeyValuePairs<TKey,TValue> Members
Overload List
DuplicateHandling
Used By
Int32 BPlusTreeTestBulkInsert.TestMergeSortedEnumerations()